package com.mbyte.easy.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mbyte.easy.admin.entity.Group;
import com.mbyte.easy.admin.mapper.GroupMapper;
import com.mbyte.easy.admin.service.IGroupService;
import com.mbyte.easy.security.entity.SysUser;
import com.mbyte.easy.security.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 板块负责人与组ID关系表 服务实现类
 * </p>
 *
 * @author lp
 * @since 2019-12-16
 */
@Service
public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements IGroupService {

    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private GroupMapper groupMapper;

    @Override
    public SysUser getUserByUserName(String username) {
        return sysUserMapper.selectByUsername(username);
    }

    @Override
    public boolean existGroupName(String name){
        Group group = this.getOne(new QueryWrapper<Group>().lambda()
                .eq(Group::getName,name));
        if(group != null){
            return true;//
        }
        return false;
    }

    @Override
    public String getNameByGroupId(String groupId) {
        return groupMapper.getNameByGroupId(groupId);
    }

}
